import { Component } from "react";
import { Form } from "antd";
import { FormHelper } from "../form-helper";
import CategoryModel from "../model/category.model";
import { categoryService } from "../service/category.service";

export interface ICategoryProps { 
    model: CategoryModel;
    name: string;
}

export default class Category extends Component<ICategoryProps> { 
    onSubmit = async (fields: any) => {
        await categoryService.save(fields);
        alert("保存成功");
    }

    render() { 
        return FormHelper.create(this.props.model, this.props.name, this.onSubmit);
    }
}